﻿// -----------------------------------------------------------------------
// Copyright (c) David Kean. All rights reserved.
// -----------------------------------------------------------------------
using System;
using System.IO;
using System.Reflection;
using Moq;

namespace Portable
{
    public static class MemberInfoFactory
    {
        public static MemberInfo OverrideGetCustomAttributes(Func<bool, object[]> action)
        {
            var mock = MockFactory.CreateMock<MemberInfo>();
            mock.Setup(m => m.GetCustomAttributes(It.IsAny<bool>()))
                .Returns(action);

            return mock.Object;
        }

        public static MemberInfo OverrideGetCustomAttributes(Func<Type, bool, object[]> action)
        {
            var mock = MockFactory.CreateMock<MemberInfo>();
            mock.Setup(m => m.GetCustomAttributes(It.IsAny<Type>(), It.IsAny<bool>()))
                .Returns(action);

            return mock.Object;
        }

        public static MemberInfo OverrideIsDefined(Func<Type, bool, bool> action)
        {
            var mock = MockFactory.CreateMock<MemberInfo>();
            mock.Setup(m => m.IsDefined(It.IsAny<Type>(), It.IsAny<bool>()))
                .Returns(action);

            return mock.Object;
        }
    }
}
